package com.example.demo.neo4j.controller;

import com.example.demo.neo4j.entity.UserNode;
import com.example.demo.neo4j.repository.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author sl shilun217@qq.com
 * @Deacription
 * @date 2021/11/20/23:06
 **/
@RestController
@RequestMapping("/neo4j")
public class Neo4jController {
    private Logger log = LoggerFactory.getLogger(this.getClass());
    @Autowired
    UserRepository userRepository;

    @PostMapping("/createUserNode")
    public UserNode createUserNode(@RequestBody UserNode userNode){
        System.out.println(userRepository);
        UserNode save = userRepository.save(userNode);
        log.info(save.toString());
        return save;
    }

    @DeleteMapping("/del/userNodeById/{id}")
    public void delAll(@PathVariable(value = "id") String id){
        userRepository.deleteById(new Long(27));

    }

}
